function core(id, msgStr, metadataStr, msgType) {
    var msg;
    var metadata;
    if (Object.prototype.toString.call(msgStr) === "[object String]") {
        msg = JSON.parse(msgStr);
    } else {
        msg = msgStr;
    }
    if (Object.prototype.toString.call(metadataStr) === "[object String]") {
        metadata = JSON.parse(metadataStr);
    } else {
        metadata = metadataStr;
    }
    return JSON.stringify(custom(id, msg, metadata, msgType))


    // 以下是真实执行方法
    function custom(id, msg, metadata, msgType) {

        return {
            url: msg.url,
            heard: msg.heard,
            params: msg.params
        };
    }
}

let s = core(1, {
    url: "http://127.0.0.1:8080/pushMsg",
    heard: {},
    params: {
        username: "admin",
        password: "admin"
    }
}, {}, 'JSON');
console.log(s)